package com.jd.finance.core.controller.admin;

import com.jd.finance.core.service.LoanApplyService;
import com.jd.finance.core.service.impl.AdminUtilsServiceImpl;
import com.jd.finance.result.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@Api(tags = "签约界面")
@RestController
@RequestMapping("/admin/core/adminAppCenter")
public class AdminSignController {

    @Resource
    private AdminUtilsServiceImpl adminUtilsService;

    @Resource
    private LoanApplyService loanApplyService;

    @ApiOperation("根据贷款申请id，获取贷款详情")
    @GetMapping("/getLoanDetailInfo")
    public BaseResult getLoanDetailInfo(Integer loanAppId,Integer uid) {
        if (uid==null || loanAppId==null) {
            log.error("签约界面查询申请信息，信息为空!");
            return BaseResult.error().message("签约界面查询申请信息，信息为空!");
        }

        if (!adminUtilsService.isBank(uid)) {
            log.error("该用户非信贷员身份!");
            return BaseResult.error().message("该用户非信贷员身份!");
        }

        return loanApplyService.getLoanDetailInfo(loanAppId,uid);
    }
}
